package com.demo.spring.IOC的源码分析;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;

/**
 * 自定义工厂后处理器，复写postProcessBeanFactory方法，获取bean定义后添加属性mobile=110
 * @ClassName:MyBeanFactoryPostProcessor
 * @Description:自定义工厂后处理器
 */
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {

	public MyBeanFactoryPostProcessor() {
		super();
		System.out.println("[MyBeanFactoryPostProcessor工厂后处理器]BeanFactoryPostProcessor实现类构造器！！");
	}

	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory arg0) throws BeansException {
		BeanDefinition bd = arg0.getBeanDefinition("messageService");
		if(bd != null){
			System.out.println("[MyBeanFactoryPostProcessor工厂后处理器]BeanFactoryPostProcessor.postProcessBeanFactory()获取bean定义后添加属性mobile=110");
			bd.getPropertyValues().addPropertyValue("mobile", "110");
		}
	}

}